integer listen_id;
integer channel_dialog =666;
integer Debug_State=0;
integer channel_Update=1336;
integer pin = 15385;
key objektKey;
Debug(string _text)
{
	if(Debug_State==0)llSay(DEBUG_CHANNEL, _text);
}

makeUpdate()
{
	llSetText("Update Start",<1,0,1>, 1);
	integer _Scripts = llGetInventoryNumber(INVENTORY_SCRIPT); 
   	integer i=0;
   	while(i<_Scripts)
   	{
   		string _Name;
   		_Name= llGetInventoryName(INVENTORY_SCRIPT, i);
   		if(_Name!=llGetScriptName())
   		{
   			llSetText("Update Script: "+(string)i+" of "+(string)(_Scripts-1),<1,0,1>, 1);
   			llRemoteLoadScriptPin( objektKey, _Name, pin, TRUE, 0);
   		}
   		i++; 
    }
    llSetText("Update done",<1,0,1>, 1);
    llListenRemove(listen_id);
	llSay(channel_Update,llKey2Name(llGetOwner()));
	llSleep(5.0);
	llResetScript();
	
}
default 
{
	
    state_entry() 
    {
        listen_id = llListen( channel_Update, "", NULL_KEY, "");
        llSetText("DV Updater",<1,0,1>, 1);
    }
    
    listen(integer channel, string name, key id, string message)
    {
    	if(message==llKey2Name(llGetOwner()))
    	{
    		objektKey=id;
    		makeUpdate();
    	}
    }
    
    link_message(integer sender, integer num, string str, key id)
  	{
		
  	}
  	
  	timer()
  	{
  	
  	}
  	
}
